/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.nazaweb.jboot.afk;

import java.awt.AWTException;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author user
 */
public class MouseClickCallback implements ICallback {

    private Point mouseClickPoint;
    private Robot robot;

    public MouseClickCallback(Point mouseClickPoint) throws AWTException {
        this.mouseClickPoint = mouseClickPoint;
        robot = new Robot();
    }

    @Override
    public void execute() {
        try {
            Thread.sleep(1000);
            robot.mouseMove(mouseClickPoint.x, mouseClickPoint.y);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        } catch (InterruptedException ex) {
            Logger.getLogger(MouseClickCallback.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
